package com.sc.nft.admin.controller;

import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.dto.AddMenuDTO;
import com.sc.nft.dto.IdRequest;
import com.sc.nft.dto.ModifyMenuDTO;
import com.sc.nft.feign.MerchantMenuClient;
import com.sc.nft.sup.Result;
import com.sc.nft.vo.PermissionListMenuVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 产品菜单列表(MerchantMenu)表控制层
 *
 * @author wwc
 * @since 2023-03-28 11:05:27
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("admin/merchantMenu")
@Api(tags = "产品菜单列表操作")
public class MerchantMenuController {

    /**
     * 服务对象
     */
    private final MerchantMenuClient merchantMenuClient;

//    @PostMapping(value = "addMenus", produces = MediaType.APPLICATION_JSON_VALUE)
//    @ApiOperation(value = "新增菜单对象整体,例如:主+子集+权限 or 主+子 or 子+权限 or 子集", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
//    @SysMemberLogin
//    public Result addPermissionMenu(@RequestBody AddMenusDTO addMenusDTO) {
//        merchantMenuClient.addPermissionMenu(addMenusDTO);
//        return Result.success();
//    }

    @PostMapping(value = "deleteMenu", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "删除菜单", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result deleteMenu(@RequestBody IdRequest idRequest) {
        return merchantMenuClient.deleteMenu(idRequest);
    }

    @PostMapping(value = "modifyMenu", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "修改菜单", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result modifyMenu(@RequestBody ModifyMenuDTO modifyMenuDTO) {
        return merchantMenuClient.modifyMenu(modifyMenuDTO);
    }

    @PostMapping(value = "addMenu", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "新增菜单,该接口只新增一条给定数据. 父级的ID和条目类型完全由前端确定.", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result addMenu(@RequestBody AddMenuDTO addMenuDTO) {
        return merchantMenuClient.addMenu(addMenuDTO);
    }

    @PostMapping(value = "permissionListMenus", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "查询所有菜单", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<List<PermissionListMenuVO>> permissionListMenus() {
        return merchantMenuClient.permissionListMenus();
    }

}
